
import * as constant from '../../constant'
const initState = {
    email: '',
    bio: '',
    avatar: null,
    following: false,
    followers: [],
    errors: null,

}

const profileReducer = (state = initState, action) => {

    switch (action.type) {
        case constant.PROFILE_GET_RESULT:
            console.log('reducer result:', action.result)
            if (action.result.status === 1) {
                return { ...state, ...action.result.data }
            } else {
                return { ...state, errors: { message: action.result.message } }
            }
        case constant.PROFILE_UNLOAD:
            return { ...initState }
        case constant.PROFILE_FOLLOW_RESULT:
            console.log('reducer result:', action.result)
            if (action.result.status === 1) {
                return { ...state, ...action.result.data }
            } else {
                return { ...state, errors: { message: action.result.message } }
            }


        default:
            break;
    }

    return state
}

export default profileReducer